package com.highspeed.bdk.gateway.socket.analyze.preset.deploy.response.storage.result;

import com.highspeed.bdk.gateway.Util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.Map;

public class AppResult {
    private Log logger = LogFactory.getLog(getClass());

    public Map<String, Object> resolve(byte[] response) {
        int offset = 0;

        //帧头
        int frameHead = Util.getInt(response, offset);
        offset += 4;
        logger.info("帧头.........." + frameHead);

        //消息长度
        int length = Util.getInt(response, offset);
        offset += 4;
        logger.info("消息长度.........." + length);

        //源逻辑ID
        short srcLogicalId = Util.getShort(response, offset);
        offset += 2;
        logger.info("源逻辑ID.........." + srcLogicalId);

        //目的逻辑ID
        short destLogicalId = Util.getShort(response, offset);
        offset += 2;
        logger.info("目的逻辑ID.........." + destLogicalId);

        //消息类型
        byte type = Util.getByte(response, offset);
        offset += 1;
        logger.info("消息类型.........." + type);

        //消息类别  F0
        byte classic = Util.getByte(response, offset);
        offset++;
        logger.info("消息类别.........." + classic);


        //消息ID
        short messageId = Util.getShort(response, offset);
        offset += 2;
        logger.info("消息ID.........." + messageId);

        //消息发送时间
        long mills = Util.getInt(response, offset);
        offset += 4;
        logger.info("消息发送时间..........毫秒数...." + mills);
        long naos = Util.getInt(response, offset);
        offset += 4;
        logger.info("消息发送时间..........纳秒数" + naos);


        //消息发送序号
        short seq = Util.getShort(response, offset);
        offset += 2;
        logger.info("消息发送序号.........." + seq);

        //保留
        short reserved = 0;
        offset += 6;
        logger.info("保留.........." + reserved);

        //命令编号 暂时不填
        offset += 20;


        //预置表编号
        short no = Util.getShort(response, offset);
        offset += 2;
        logger.info("预置表编号.........." + no);

        //存储结果
        byte storage = Util.getByte(response, offset);
        offset += 1;
        logger.info("存储结果.........." + storage);

        //帧尾
        int frameTail = Util.getInt(response, offset);
        offset += 4;
        logger.info("帧尾.........." + frameTail);

        return null;
    }

}
